/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

/**
 *
 * @author dingnangen
 */
public class Result<T> {
	public static final String SUCCESS_MSG="操作成功";
	public static final String ERROR_MSG="操作失败";
	public static final String EMPTY_MSG="";
	public static final String SEARCH_EMPTY_MSG="查询不到数据";
	public enum StatusEnum{
		success,//成功
		failure,//失败
		error,//错误
		notlogin,//未登录
		noPriv,//无权限
		info,//信息提示
	}
	
	private StatusEnum status;
	private String msg;//返回信息
	private Object obj;//自定数据
	
	private T data;//自定数据
	
	public Result() {
		super();
	}
	public Result(StatusEnum status, String msg) {
		super();
		this.status = status;
		this.msg = msg;
	}
	public Result(StatusEnum status, String msg, Object obj) {
		super();
		this.status = status;
		this.msg = msg;
		this.obj = obj;
	}
	
	public T getData() {
		return data;
	}
	public void setData(T data) {
		this.data = data;
	}
	public StatusEnum getStatus() {
		return status;
	}
	public void setStatus(StatusEnum status) {
		this.status = status;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object getObj() {
		return obj;
	}
	public void setObj(Object obj) {
		this.obj = obj;
	}
	
	public static Result error(String msg){
		return new Result(StatusEnum.error,msg);
	}
	
	public static Result success(String msg){
		return new Result(StatusEnum.success,msg);
	}
	
	public static Result success(Object obj){
		return new Result(StatusEnum.success,SUCCESS_MSG,obj);
	}
	
	public static Result info(String msg){
		return new Result(StatusEnum.info,msg);
	}
}